package com.draven.mall.controller;

import com.draven.mall.common.ApiResponse;
import com.draven.mall.entity.Category;
import com.draven.mall.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 测试商品分类控制器 - 确认API功能正常
 */
@RestController
@RequestMapping("/api/test/category")
public class TestCategoryController {

    @Autowired
    private CategoryService categoryService;

    /**
     * 测试获取所有分类（平铺结构）
     */
    @GetMapping("/list")
    public ApiResponse testGetCategoryList() {
        List<Category> categories = categoryService.getAllCategories();
        return ApiResponse.success(categories);
    }

    /**
     * 测试获取分类树结构
     */
    @GetMapping("/tree")
    public ApiResponse testGetCategoryTree() {
        List<Category> categoryTree = categoryService.getCategoryTree();
        return ApiResponse.success(categoryTree);
    }

    /**
     * 测试获取分类详情
     */
    @GetMapping("/{id}")
    public ApiResponse testGetCategoryDetail(@PathVariable Long id) {
        Category category = categoryService.getCategoryById(id);
        return ApiResponse.success(category);
    }
} 